import { RouteRecordRaw } from 'vue-router';
import { REDIRECT_ROUTE_NAME, LOGIN_ROUTE_NAME, DEFAULT_ROUTE_NAME, OAUTH2_CALLBACK_NAME } from '@/routers/constants';

export const DEFAULT_LAYOUT = () => import('@/layout/index.vue');

/**
 * staticRouter(静态路由)
 */

export const staticRouter: RouteRecordRaw[] = [
	{
		path: '/authorize/login',
		name: LOGIN_ROUTE_NAME,
		component: () => import('@/views/login/login.vue'),
		meta: {
			requiresAuth: false,
		},
	},
	{
		path: '/authorize/oauth2/callback',
		name: OAUTH2_CALLBACK_NAME,
		component: () => import('@/views/login/callback.vue'),
		meta: {
			requiresAuth: false,
		},
	},
	{
		path: '/',
		name: 'layout',
		component: () => import('@/layout/index.vue'),
		redirect: '/dashboard/workspace',
		meta: {
			locale: '主页',
			requiresAuth: true,
			icon: 'icon-dashboard',
			order: 0,
		},
		children: [
			{
				path: '/redirect/:path',
				name: REDIRECT_ROUTE_NAME,
				component: () => import('@/views/redirect/index.vue'),
				meta: {
					requiresAuth: false,
				},
			},
		],
	},
];

/**
 * errorRouter(错误页面路由)
 */
export const errorRouter = [
	{
		path: '/403',
		name: '403',
		component: () => import('@/components/errorPages/403.vue'),
		meta: {
			title: '403页面',
		},
	},
	{
		path: '/404',
		name: '404',
		component: () => import('@/components/errorPages/404.vue'),
		meta: {
			title: '404页面',
		},
	},
	{
		path: '/500',
		name: '500',
		component: () => import('@/components/errorPages/500.vue'),
		meta: {
			title: '500页面',
		},
	},
	// 解决刷新页面，路由警告
	{
		path: '/:pathMatch(.*)*',
		component: () => import('@/components/errorPages/404.vue'),
	},
];
